import request from '../request.ts'

// 获取仪表盘数据 (暂时保留，后端可能未实现)
export const getDashboardData = () => {
  return request({
    url: '/dashboard',
    method: 'get'
  })
}

// 重新导入其他模块的接口，避免重复定义
import { 
  getMyUserGroupsList, 
  createUserGroup, 
  updateUserGroup, 
  deleteUserGroup 
} from './userGroups'

import { 
  listMyQuestions, 
  createQuestion, 
  updateQuestion, 
  deleteQuestion 
} from '../questions/questions'

import { 
  getMyExamsList, 
  createExam, 
  updateExam, 
  deleteExam 
} from '../exam/exams'

import { 
  getMyExamAssignments 
} from '../exam/examAssignments'

// 分组管理 - 重新导出
export const getGroupList = getMyUserGroupsList
export const createGroup = createUserGroup
export const updateGroup = updateUserGroup
export const deleteGroup = deleteUserGroup

// 题目管理 - 重新导出
export const getQuestionList = listMyQuestions
export { createQuestion, updateQuestion, deleteQuestion }

// 试卷管理 - 重新导出
export const getPaperList = getMyExamsList
export const createPaper = createExam
export const updatePaper = updateExam
export const deletePaper = deleteExam

// 考试安排管理 - 重新导出
export const getExamAssignmentList = getMyExamAssignments

// 阅卷管理 - 使用grading.js中的接口
export const getGradingList = () => {
  return request({
    url: '/grading/exams',
    method: 'get'
  })
}

export const gradeExam = (data) => {
  return request({
    url: '/grading/grade-single',
    method: 'post',
    data
  })
}

export const batchGrade = (data) => {
  return request({
    url: '/grading/batch-grade',
    method: 'post',
    data
  })
}

// 监控管理 - 使用monitoring.js中的接口
export const getMonitoringData = (data) => {
  return request({
    url: '/exam-sessions/monitor',
    method: 'post',
    data
  })
}

export const reportCheating = (data) => {
  return request({
    url: '/cheating/mark',
    method: 'post',
    data
  })
}

export const detectSimilarity = (data) => {
  return request({
    url: '/cheating/detect-similarity',
    method: 'post',
    data
  })
}

// 学生管理 - 使用rbac.js中的接口
export const getStudentList = () => {
  return request({
    url: '/rbac/users',
    method: 'get'
  })
}

export const createStudent = (data) => {
  return request({
    url: '/rbac/users',
    method: 'post',
    data
  })
}

export const updateStudent = (userId, data) => {
  return request({
    url: `/rbac/users/${userId}`,
    method: 'put',
    data
  })
}

export const deleteStudent = (userId) => {
  return request({
    url: `/rbac/users/${userId}`,
    method: 'delete'
  })
}